#include <cstdlib>
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    vector<int> leftRigthDifference(vector<int>& nums) {
        vector<int>leftsum(nums.size());
        vector<int>rightsum(nums.size());
        vector<int>ans(nums.size()+1);
        leftsum[0]=0;
        for(int i=1;i<leftsum.size();i++)
        {
            leftsum[i]=nums[i-1]+leftsum[i-1];
        }
        rightsum[0]=leftsum.back()+nums[nums.size()-1]-nums[0];
        for(int i=1;i<rightsum.size()-1;i++){
            rightsum[i]=rightsum[i-1]-nums[i];
        }
        for(int i=0;i<nums.size()+1;i++)
        {
            ans.push_back(abs(rightsum[i]-leftsum[i]));
        }
        return ans;

    }
};
int main()
{
    vector<int> nums({10,4,8,3});
    Solution s1;
    s1.leftRigthDifference(nums);
}